<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>调查问卷管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			
			var displayType = '${questionnaire.type}';
			   if(displayType =='') displayType ="0";
			   $("input[name='type'][value="+displayType+"]").attr("checked","checked");  

		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/questionnaire/">调查问卷列表</a></li>
		<li><a href="${ctx}/wechat/questionnaire/form?id=${questionnaire.id}&type=0">调查问卷<shiro:hasPermission name="wechat:questionnaire:edit">${not empty questionnaire.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:questionnaire:edit">查看</shiro:lacksPermission></a></li>
		<li  class="active"><a href="${ctx}/wechat/questionnaire/form?id=${questionnaire.id}&type=1">一战到底<shiro:hasPermission name="wechat:questionnaire:edit">${not empty questionnaire.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:questionnaire:edit">查看</shiro:lacksPermission></a></li>
		<li><a href="${ctx}/wechat/questionnaire/form?id=${questionnaire.id}&type=2">投票<shiro:hasPermission name="wechat:questionnaire:edit">${not empty questionnaire.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:questionnaire:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="questionnaire" action="${ctx}/wechat/questionnaire/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
			<form:hidden path="type" value="1"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">标题:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false"  class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">描述:</label>
			<div class="controls">
				<form:textarea id="description" cols="10" rows="5" path="description"></form:textarea>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否重复提交:</label>
			<div class="controls">
				<form:radiobutton path="isRepeat" value="1"/>是
				<form:radiobutton path="isRepeat" value="0"/>否
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">活动处理器选择:</label>
			<div class="controls">
				<form:select path="activityConfig.id">
					<form:option value="">请选择</form:option>
					<c:forEach items="${activityConfigList }" var="activityConfig">
					<form:option value="${activityConfig.id }">${activityConfig.name }</form:option>
					
					</c:forEach>
				</form:select><span class="alert">此为选择活动处理器，当选为一站到底模式时，请选择，否则一站到底不生效</span>
			</div>
		</div>
		
		
		<div class="form-actions">
			<shiro:hasPermission name="wechat:questionnaire:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
